package com.code.wflow.constants;

import com.code.wflow.node.*;

import java.lang.reflect.Type;

/**
 * @author ggh
 * @date 2022/11/10
 */
public enum NodeTypeEnum {
    START("ROOT", "开始节点", RootNodeProperties.class),
    APPROVAL("APPROVAL", "审批节点", ApprovalNodeProperties.class),
    CC("CC", "抄送节点", CCNodeProperties.class),
    CONIDITIONS("CONDITIONS", "条件组节点", ConditionsNodeProperties.class),
    CONIDITION("CONDITION", "条件节点", ConditionNodeProperties.class),
    EMPTY("EMPTY", "空节点", EmptyNodeProperties.class),
    DELAY("DELAY", "延迟器", DelayNodeProperties.class),
    TRIGGER("TRIGGER", "触发器", TriggerNodeProperties.class);

    NodeTypeEnum(String type, String msg, Type cls) {
        this.type = type;
        this.msg = msg;
        this.cls = cls;
    }

    private String type;

    private String msg;

    private Type cls;

    public String getMsg() {
        return msg;
    }

    public String getType() {
        return type;
    }

    public Type getCls() {
        return cls;
    }

    public static NodeTypeEnum parse(String type) {
        for (NodeTypeEnum typeEnum : values()) {
            if (typeEnum.getType().equals(type)) {
                return typeEnum;
            }
        }
        return null;
    }
}
